package com.woniuxy.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 〈一句话功能简述〉<br>
 * 〈获取最近7天时间〉
 *
 * @author jia
 * @create 2019/9/27
 * @since 1.0.0
 */
public class DateUtil {

    public static String getDate(String d) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date day = sdf.parse(d);
        long ms = day.getTime() - 1*24*3600*1000L;
        Date prevDay = new Date(ms);
        //System.out.println(sdf.format(prevDay));
        return sdf.format(prevDay);
    }

    public static void main(String[] args) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        String d = sdf.format(date);
        String  str = getDate(d);
        String str2 = getDate(str);
       String str3 = getDate(str2);
    }
}
